home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 40
/
Aminet 40 (2000)(Schatztruhe)[!][Dec 2000].iso
/
Aminet
/
util
/
cli
/
APT-WBOpen11.lha
/
source
/
WO.s
Wrap
Text File
|
2000-08-30
|
5KB
|
301 lines
;APS000000000000000000000F5800000000000000000000000000000000000000000000000000000000
;Written with Asm-Pro v1.16, might need some small modifications before it
;assembles with other progs..
;other assemblers..
;
;Done by Point/Apathy <s991641@stud.nhh.no>
incdir "include:"
include "all_lvos.i"
include "dos/dosextens.i"
include "exec/exec.i"
include "workbench/workbench.i"
include "libraries/asl.i"
section wbopen_code,code
wbopen_skip
bra.s wbopen
dc.b "$VER: WBOpen v1.1 by Alex Gustavsen aka Point/Apathy, 29-Aug-2000",0
cnop 0,4
wbopen movem.l d1-a6,-(sp)
bsr.s wo_nicestart
bne.w wo_rts
bsr.s wo_openlibs
bne.w wo_exit_
bsr.w main
wo_exit_
bsr.w wo_errormsg
bsr.w wo_closelibs
wo_rts movem.l (sp)+,d1-a6
rts
wo_nicestart
movem.l d1/a0-a2/a6,-(sp)
move.l 4.w,a6
move.l a6,_SysBase
sub.l a1,a1
jsr _LVOFindTask(a6)
move.l d0,a2
move.l d0,thistask
tst.l pr_CLI(a2)
bne.s wb_nicestart.ok
lea pr_MsgPort(a2),a0
jsr _LVOWaitPort(a6)
lea pr_MsgPort(a2),a0
jsr _LVOGetMsg(a6)
move.l d0,a1
jsr _LVOReplyMsg(a6)
moveq.l #RETURN_ERROR,d0
bra.s wb_nicestart.rts
wb_nicestart.ok
moveq.l #0,d0
wb_nicestart.rts
movem.l (sp)+,d1/a0-a2/a6
rts
wo_openlibs
movem.l d1/a0-a1/a6,-(sp)
move.l _SysBase,a6
lea dos_name,a1
moveq.l #36,d0
jsr _LVOOpenLibrary(a6)
tst.l d0
beq.s wo_openlibs.failed
move.l d0,dos_base
move.l #wblib_err,errormsg
lea wb_name,a1
moveq.l #44,d0
jsr _LVOOpenLibrary(a6)
tst.l d0
beq.s wo_openlibs.failed
move.l #0,errormsg
move.l d0,wb_base
moveq.l #0,d0
wo_openlibs.rts
movem.l (sp)+,d1/a0-a1/a6
rts
wo_openlibs.failed
move.l #RETURN_ERROR,d0
bra.s wo_openlibs.rts
wo_errormsg
movem.l d0-d1/a0-a1/a6,-(sp)
tst.l errormsg
beq.s wo_errormsg.rts
move.l dos_base,a6
move.l errormsg,d1
jsr _LVOVPrintf(a6)
wo_errormsg.rts
movem.l (sp)+,d0-d1/a0-a1/a6
rts
wo_closelibs
movem.l d0-d1/a0-a1/a6,-(sp)
move.l _SysBase,a6
move.l dos_base,a1
tst.l a1
beq.s wo_closelibs.rts
jsr _LVOCloseLibrary(a6)
move.l wb_base,a1
tst.l a1
beq.s wo_closelibs.rts
jsr _LVOCloseLibrary(a6)
move.l asl_base,a1
tst.l a1
beq.s wo_closelibs.rts
jsr _LVOCloseLibrary(a6)
wo_closelibs.rts
movem.l (sp)+,d0-d1/a0-a1/a6
rts
;-------_strlength:
; input a0-strptr
; output d0-length
_strlength
move.l a0,-(sp)
moveq.l #-1,d0
_strlength.loop
addq.l #1,d0
tst.b (a0)+
bne.s _strlength.loop
move.l (sp)+,a0
rts
;-------_bytecopy:
; input a0-src
; a1-dest
; d0-length
_bytecopy
movem.l d0/a0-a1,-(sp)
subq.l #1,d0
blt.s _bytecopy.rts
_bytecopy.loop
move.b (a0)+,(a1)+
dbra d0,_bytecopy.loop
_bytecopy.rts
movem.l (sp)+,d0/a0-a1
rts
main movem.l d0-a6,-(sp)
move.l dos_base,a6
move.l #argtemplate,d1
move.l #argarray,d2
moveq.l #0,d3
jsr _LVOReadArgs(a6)
tst.l d0
beq.w main.failed
move.l d0,rdargs
lea argarray,a0
tst.l (a0)
bne.w main.open_it ;name in a0
move.l _SysBase,a6
move.l #asllib_err,errormsg
lea asl_name,a1
moveq.l #36,d0
jsr _LVOOpenLibrary(a6)
tst.l d0
beq.w main.failed
move.l #0,errormsg
move.l d0,asl_base
move.l d0,a6
move.l #usage,errormsg
move.l #ASL_FileRequest,d0
lea req_tags,a0
jsr _LVOAllocAslRequest(a6)
tst.l d0
beq.w main.failed
move.l d0,req
move.l d0,a0
sub.l a1,a1
jsr _LVOAslRequest(a6)
tst.l d0
beq.w main.failed
move.l req,a1
move.l fr_File(a1),a0
jsr _strlength
move.l d0,d1
move.l fr_Drawer(a1),a0
jsr _strlength
add.l d1,d0
add.l #4,d0
move.l d0,namelen
move.l _SysBase,a6
move.l #MEMF_CLEAR,d1
jsr _LVOAllocMem(a6)
tst.l d0
beq.w main.failed
move.l d0,namebuf
move.l req,a2
move.l fr_Drawer(a2),a0
move.l namebuf,a1
jsr _strlength
jsr _bytecopy
move.l dos_base,a6
move.l a1,d1
move.l fr_File(a2),d2
move.l namelen,d3
jsr _LVOAddPart(a6)
move.l namebuf,a0
main.open_it
move.l #0,errormsg
move.l wb_base,a6
sub.l a1,a1
jsr _LVOOpenWorkbenchObjectA(a6)
tst.l d0
bne.w main.done
move.l dos_base,a6
jsr _LVOIoErr(a6)
move.l d0,d1
move.l #header,d2
jsr _LVOPrintFault(a6)
main.done
bsr.s main.freemem
main.rts
movem.l (sp)+,d0-a6
rts
main.freemem
movem.l d0-d1/a0-a1/a6,-(sp)
move.l dos_base,a6
move.l rdargs,d1
jsr _LVOFreeArgs(a6)
move.l #0,rdargs
move.l asl_base,a6
tst.l a6
beq.s main.freemem_rts
move.l req,a0
jsr _LVOFreeAslRequest(a6)
move.l #0,req
tst.l namebuf
beq.s main.freemem_rts
move.l namebuf,a1
move.l namelen,d0
move.l _SysBase,a6
jsr _LVOFreeMem(a6)
move.l #0,namebuf
main.freemem_rts
movem.l (sp)+,d0-d1/a0-a1/a6
rts
main.failed
bsr.s main.freemem
move.l #RETURN_ERROR,d0
bra.s main.rts
section wbopen_data,data
nullstr macro
dc.b \1,0
even
endm
dos_name nullstr "dos.library"
wb_name nullstr "workbench.library"
asl_name nullstr "asl.library"
dos_base dc.l 0
wb_base dc.l 0
asl_base dc.l 0
_SysBase dc.l 0
thistask dc.l 0
errormsg dc.l 0
argarray dc.l 0
rdargs dc.l 0
req dc.l 0
namebuf dc.l 0
namelen dc.l 0
currentdir dc.l 0
wblib_err dc.b "Unable to open workbench.library v44 or higher",10,0
asllib_err dc.b "Unable to open asl.library v36 or higher",10,0
argtemplate nullstr "NAME/F"
usage dc.b "WbOpen v1.1 by Alex Gustavsen aka Point/Apathy",10,"Usage: WO <file/drawer/whatever>",10,0
req_tags dc.l ASLFR_TitleText,req_title
dc.l ASLFR_RejectIcons,1
dc.l ASLFR_PrivateIDCMP,1
dc.l TAG_DONE,0
req_title nullstr "WBOpen v1.1 © Point/Apathy"
header nullstr "Error:"